package com.tsit.study.dubbo.provider.service;

import com.tsit.study.dubbo.provider.api.UserService;
import com.tsit.study.dubbo.provider.entity.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangxuzhi
 * @date 2020/11/17 17:08
 */
@Service
@DubboService(loadbalance = "roundrobin")
public class UserServiceImpl implements UserService {

    @Value("${server.port}")
    private String port;

    @Override
    public List<User> getUserList() {
        List<User> userList = new ArrayList<>();

        User user1 = new User();
        user1.setUsernmae("admin");
        user1.setAge(10);
        user1.setPassword("password");
        userList.add(user1);

        User user2 = new User();
        user2.setUsernmae("root");
        user2.setAge(10);
        user2.setPassword("password");
        userList.add(user2);

        User user3 = new User();
        user3.setUsernmae("wangxuzhi");
        user3.setAge(20);
        user3.setPassword("tsit123456");
        userList.add(user3);

        return userList;
    }

    @Override
    public String getUserInfo() {
        return "hello world:" + port;
    }
}
